import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UserFinancingVO, UserFinancingForm, UserFinancingQuery } from '@/api/business/userFinancing/types';

/**
 * 查询用户理财记录列表
 * @param query
 * @returns {*}
 */

export const listUserFinancing = (query?: UserFinancingQuery): AxiosPromise<UserFinancingVO[]> => {
  return request({
    url: '/business/userFinancing/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户理财记录详细
 * @param id
 */
export const getUserFinancing = (id: string | number): AxiosPromise<UserFinancingVO> => {
  return request({
    url: '/business/userFinancing/' + id,
    method: 'get'
  });
};

/**
 * 新增用户理财记录
 * @param data
 */
export const addUserFinancing = (data: UserFinancingForm) => {
  return request({
    url: '/business/userFinancing',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户理财记录
 * @param data
 */
export const updateUserFinancing = (data: UserFinancingForm) => {
  return request({
    url: '/business/userFinancing',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户理财记录
 * @param id
 */
export const delUserFinancing = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/userFinancing/' + id,
    method: 'delete'
  });
};
